﻿using UnityEngine;

namespace Assets.Script.gamecore.unit
{
    public class UnityObject
    {
#if _UNITYLOGIC_
        //游戏单位
        public GameObject _gameObject;
#endif
        //最后的位置
        FixVector3 _LastPosition = new FixVector3(Fix64.Zero, Fix64.Zero, Fix64.Zero);

        //逻辑位置
        FixVector3 _LogicPosition = new FixVector3(Fix64.Zero, Fix64.Zero, Fix64.Zero);

        //旋转
        FixVector3 _LogicRotation;

        //缩放
        FixVector3 _LogicScale;

        //物体是否能移动
        bool _CanMove;

        public void UpdateRenderPosition(float interpolation)
        {
#if _UNITYLOGIC_
            if(_CanMove)
            {
                //逻辑位置和表现位置之间做差值
                _gameObject.transform.localPosition = Vector3.Lerp(_LastPosition.ToVector3(), _LogicPosition.ToVector3(), interpolation);
            }
            else
            {
                _gameObject.transform.localPosition = _LogicPosition.ToVector3();
            }
#endif
        }

        //创建prefab
        public void CreateFromPrefab(string path)
        {
#if _UNITYLOGIC_

#endif
        }
        public void SetGameOjbectPosition(FixVector3 position)
        {
#if _UNITYLOGIC_
            _gameObject.transform.localPosition = position.ToVector3();
#endif
        }

        public void SetLogicPosition(FixVector3 pos)
        {
            _LogicPosition = pos;
        }
    }
}
